package com.gsafety.wellsfort.domain.vo;

import com.gsafety.wellsfort.domain.form.Tree;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
@Data
public class MenuVO {
    @ApiModelProperty(value = "菜单id")
    private Integer id;

    /**
     * 菜单名称
     */
    @ApiModelProperty(value = "菜单名称")
    private String name;

    /**
     * 图标
     */
    @ApiModelProperty(value = "图标")
    private String icon;

    /**
     * 视图层级码
     */
    @ApiModelProperty(value = "视图层级码")
    private String viewCode;

    @ApiModelProperty(value = "子节点")
    private  List<MenuVO> children;

    public MenuVO(Integer id, String name, String icon, String viewCode) {
        this.id = id;
        this.name =name;
        this.icon = icon;
        this.viewCode = viewCode;
    }

    public void addChildren(MenuVO tree){
        if(this.children == null){
            this.children = new ArrayList<>();
        }
        this.children.add(tree);
    }
}
